package cn.four.shop.controller;

import cn.four.shop.mapper.AdminMapper;
import cn.four.shop.pojo.dto.AdminDTO;

import cn.four.shop.pojo.vo.AdminVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class AdminController {


    @Autowired(required = false)
    AdminMapper mapper;
    @RequestMapping("/login/admin")
    public int loginAdmin(@RequestBody AdminDTO admin){
      System.out.println("admin = " + admin);
      AdminVO a = mapper.selectByUsername(admin.getUsername());
      System.out.println("admin = " + a);
      if (a!=null){
          if (a.getPassword().equals(admin.getPassword())){
              return 1;
          }
          return 3;
      }
        return 2;
  }

}
